$(window).load(function(){
        
        $('.freplace').each(function(i){

                    var attr;
                    var width = $(this).attr('ref');
                    var title = $(this).attr('rel');
                    var img = $(this).attr('img');
                    var element = $(this);
                    var pic_real_width, pic_real_height;

                    attr = [
                        {'posh' : 'left', 'posv' : 'top', 'width' : width}
                    ];

                    element.css('text-indent', '-11111em');

                    $("<img/>")
                        .attr("src", img)
                        .load(function() {
                            pic_real_width = this.width; 
                            pic_real_height = this.height;
                            element.css('background', 'url("'+img+'") no-repeat scroll '+attr[0].posh+' '+attr[0].posv+' transparent');
                            element.css('width', pic_real_width+'px');
                            element.css('height', pic_real_height+'px');
                    });

                    element.css('background', 'url("'+img+'") no-repeat scroll '+attr[0].posh+' '+attr[0].posv+' transparent');

            });
       
 });       